//
//  MatchingViewController.m
//  Zinipad
//
//  Created by ZeLkOvA on 12. 6. 25..
//  Copyright (c) 2012년 __MyCompanyName__. All rights reserved.
//

#import "MatchingViewController.h"
#import <QuartzCore/QuartzCore.h>

@interface MatchingViewController ()

@end

@implementation MatchingViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
//    UIView *view = [[UIView alloc] init];
//    [view setFrame:CGRectMake(200, 100, 1024/3, 768/1.5f)];
//    UIImage* leftMenuTitleImage = [UIImage imageNamed:@"x"];
//    UIImageView* leftMenuTitleImageView  = [[UIImageView alloc] initWithImage:leftMenuTitleImage];
//    [leftMenuTitleImageView setFrame:CGRectMake(0, 0, 1024/3, 768/1.5f)];
//    [view addSubview:leftMenuTitleImageView];
//
//    CALayer *layer = view.layer;
//    CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
//    rotationAndPerspectiveTransform.m34 = 1.0 / -500;
//    rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 25.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
//    layer.transform = rotationAndPerspectiveTransform;
//    
//    [self.view addSubview:view];
//    
//    UIView *view2 = [[UIView alloc] init];
//    [view2 setFrame:CGRectMake(130+1024/3, 100, 1024/3, 768/1.5f)];
//    UIImage* MenuTitleImage = [UIImage imageNamed:@"y"];
//    UIImageView* MenuTitleImageView  = [[UIImageView alloc] initWithImage:MenuTitleImage];
//    [MenuTitleImageView setFrame:CGRectMake(0, 0, 1024/3, 768/1.5f)];
//    [view2 addSubview:MenuTitleImageView];
//    
//    CALayer *layer2 = view2.layer;
//    CATransform3D rotationAndPerspectiveTransform2 = CATransform3DIdentity;
//    rotationAndPerspectiveTransform2.m34 = 1.0 / -500;
//    rotationAndPerspectiveTransform2 = CATransform3DRotate(rotationAndPerspectiveTransform2, -25.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
//    layer2.transform = rotationAndPerspectiveTransform2;
//    [self.view addSubview:view2];
//    UIImage* a = [UIImage imageNamed:@"img_left_box.png"];
//   UIImage* b = [UIImage imageNamed:@"img_right_slice_box.png"];
//   
//    UIImage* abc = [self maskingImage:a maskImage:@"img_right_slice_box"];
//    UIImageView* ImageView  = [[UIImageView alloc] initWithImage:abc];
//    [ImageView setFrame:CGRectMake(200, 100, 330, 441)];
//    [ImageView setBackgroundColor:[UIColor clearColor]];
//    [self.view addSubview:ImageView];
	// Do any additional setup after loading the view.
    
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(UIImage *)maskingImage:(UIImage *)image maskImage:(NSString*)_maskImage
{
	
	CGImageRef imageRef = [image CGImage];
	CGImageRef maskRef = [[UIImage imageNamed:_maskImage] CGImage];
    
	CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
										CGImageGetHeight(maskRef),
										CGImageGetBitsPerComponent(maskRef),
										CGImageGetBitsPerPixel(maskRef),
										CGImageGetBytesPerRow(maskRef),
										CGImageGetDataProvider(maskRef),
										NULL, false);
    
	CGImageRef masked = CGImageCreateWithMask(imageRef, mask);
	CGImageRelease(mask);
    
	UIImage *maskedImage = [UIImage imageWithCGImage:masked];
	CGImageRelease(masked);
	
	return maskedImage;
}
@end
